package com.ruoyi.common.core.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class CustomDataConfig {

    //编辑表单项
    @Data
    public static class EditFormItemInf implements Serializable {
        private String type;        //类型 ELEMENT_TYPE
        private String label;        //显示标题
        private String prop;        //model 的键名
        private boolean show = true;        //是否显示
        private Integer span = 8;        //宽 1-24 之间
        private String key;        //提交字段
        private String vif = "true";        //显示条件
        private String defaultVal;        //默认值
        private boolean disabled = false;        //是否可编辑
        private String yes;        //开关选中对应的值
        private String no;        //开关关闭对应的值
        private String placeholder;        //输入框占位文本
        private List<Map<String, Object>> rules = new ArrayList<>();
        private String dictType; //数据源url地址。下拉框返回List<SelectOptionBO>

        private String color = "primary";        // 按钮颜色
        private boolean link = true;        //文本按钮
        private String icon;        //图标
        private String optType = "DIALOG"; //动作类型    常量类TABLE_ROW_BUTTON_OPT_TYPE ：PAGE   URL  DIALOG
        private boolean btnInTable = true; //按钮在表格内

        private EditFormInf editForm = new EditFormInf(); //按钮对应的form

        private String url;        //button 对应的请求地址
        private boolean circle = false;        //圆形
        private boolean merge = false;        //table行是否合并
        private String size;        //按钮尺寸 'large'| 'default'| 'small'
        private String width;        //宽
        private String linkCustomDataId;            //是否数据钻取sql id

        public EditFormItemInf setKey(String key) {
            this.key = key;
            return this;
        }
    }

    //编辑表单项
    @Data
    public static class EditFormInf implements Serializable {
        private String url;        //提交url
        private String path; //组件地址,当为NEW-PAGE 时必传
        private String getByIdUrl;        //提交url
        private String width;        //宽
        private String cols;        //表单列数
        private String component;        //组件
        private String tips; //提示文本,当为URL 时必传
        private boolean initialize = true;        //是否初始化
        private List<EditFormItemInf> items = new ArrayList<>();

    }

    @Data
    public static class MetaInf implements Serializable {
        private String sql;
        private List<EditFormItemInf> columns = new ArrayList<>();        //table显示列
        private List<EditFormItemInf> rowButtons = new ArrayList<>();        //行操作按钮
        private List<EditFormItemInf> conditions = new ArrayList<>();    //查询条件
        private TreeInf tree = new TreeInf();        //数据类型  table  table-tree

        private String linkCustomDataId;            //是否数据钻取sql id

        private String isTreeTable;

    }

    @Data
    public static class TreeInf implements Serializable {
        private String rootId = "0";        //属性字段
        private String childrenKey = "children";            //表头
        private String idKey = "id";            //是否数据钻取sql id
        private String parentIdKey = "parent_id";            //是否数据钻取sql id
        private String nameKey = "name";            //表头

    }


}
